%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/interfaces-relational/commentables-simple"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 9, 119, 10<br />2: PgSelect[7]<br />3: PgSelectRows[12]<br />4: __ListTransform[11]"):::bucket
    Bucket1("Bucket 1 (subroutine)<br /><br />ROOT PgSelectSingle{1}ᐸrelational_commentablesᐳ[14]"):::bucket
    Bucket2("Bucket 2 (listItem)<br />Deps: 10<br /><br />ROOT __Item{2}ᐸ11ᐳ[15]"):::bucket
    Bucket3("Bucket 3 (polymorphic)<br />__typename: Lambda[21]<br />Deps: 21, 10, 17"):::bucket
    Bucket4("Bucket 4 (polymorphicPartition)<br />|RelationalPost<br />Deps: 10, 17<br />ᐳRelationalPost<br /><br />1: PgSelectInlineApply[107]<br />2: PgSelect[23]<br />ᐳ: Access[108]<br />3: PgSelectRows[28]<br />ᐳ: 27, 29, 109, 110<br />4: PgSelectRows[50]<br />ᐳ: 49, 51, 52, 76, 94"):::bucket
    Bucket5("Bucket 5 (polymorphicPartition)<br />|RelationalChecklist<br />Deps: 10, 17<br />ᐳRelationalChecklist<br /><br />1: PgSelectInlineApply[111]<br />2: PgSelect[30]<br />ᐳ: Access[112]<br />3: PgSelectRows[35]<br />ᐳ: 34, 36, 113, 114<br />4: PgSelectRows[59]<br />ᐳ: 58, 60, 61, 82, 100"):::bucket
    Bucket6("Bucket 6 (polymorphicPartition)<br />|RelationalChecklistItem<br />Deps: 10, 17<br />ᐳRelationalChecklistItem<br /><br />1: PgSelectInlineApply[115]<br />2: PgSelect[37]<br />ᐳ: Access[116]<br />3: PgSelectRows[42]<br />ᐳ: 41, 43, 117, 118<br />4: PgSelectRows[68]<br />ᐳ: 67, 69, 70, 88, 106"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4 & Bucket5 & Bucket6

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸrelational_commentablesᐳ<br />More deps:<br />- Object[10]<br />- Constantᐸ1ᐳ[119]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 4"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    __ListTransform11[["__ListTransform[11∈0] ➊<br />ᐸeach:7ᐳ<br />More deps:<br />- PgSelectRows[12]"]]:::plan
    PgSelectRows12[["PgSelectRows[12∈0] ➊<br />Dependents: 2"]]:::plan
    PgSelect7 --> PgSelectRows12
    __Item13[/"__Item[13∈1]<br />ᐸ12ᐳ<br />More deps:<br />- PgSelectRows[12]"\]:::itemplan
    PgSelectSingle14{{"PgSelectSingle[14∈1]<br />ᐸrelational_commentablesᐳ"}}:::plan
    __Item13 --> PgSelectSingle14
    __Item15[/"__Item[15∈2]<br />ᐸ11ᐳ"\]:::itemplan
    __ListTransform11 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈2]<br />ᐸrelational_commentablesᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__relation...les__.”id”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgClassExpression19{{"PgClassExpression[19∈2]<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression19
    Lambda21{{"Lambda[21∈2]<br />ᐸrelationalItemTypeNameFromTypeᐳ"}}:::plan
    PgClassExpression19 -->|rejectNull| Lambda21
    PgSelect23[["PgSelect[23∈4]^<br />ᐸrelational_postsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgSelectInlineApply107["PgSelectInlineApply[107∈4] ➊<br />ᐳRelationalPost"]:::plan
    PgClassExpression17 -->|rejectNull| PgSelect23
    PgSelectInlineApply107 --> PgSelect23
    List109{{"List[109∈4]^<br />ᐸ108,29ᐳ"}}:::plan
    Access108{{"Access[108∈4]^<br />ᐸ23.m.joinDetailsFor45ᐳ"}}:::plan
    PgSelectSingle29{{"PgSelectSingle[29∈4]^<br />ᐸrelational_postsᐳ"}}:::plan
    Access108 & PgSelectSingle29 --> List109
    First27{{"First[27∈4]^"}}:::plan
    PgSelectRows28[["PgSelectRows[28∈4]^"]]:::plan
    PgSelectRows28 --> First27
    PgSelect23 --> PgSelectRows28
    First27 --> PgSelectSingle29
    First49{{"First[49∈4]^"}}:::plan
    PgSelectRows50[["PgSelectRows[50∈4]^"]]:::plan
    PgSelectRows50 --> First49
    Lambda110{{"Lambda[110∈4]^<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda110 --> PgSelectRows50
    PgSelectSingle51{{"PgSelectSingle[51∈4]^<br />ᐸrelational_itemsᐳ"}}:::plan
    First49 --> PgSelectSingle51
    PgClassExpression52{{"PgClassExpression[52∈4]^<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle51 --> PgClassExpression52
    PgClassExpression76{{"PgClassExpression[76∈4]^<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgClassExpression52 o--o PgClassExpression76
    PgClassExpression94{{"PgClassExpression[94∈4]^<br />ᐸ__relation...”position”ᐳ"}}:::plan
    PgClassExpression76 o--o PgClassExpression94
    PgSelect23 --> Access108
    List109 --> Lambda110
    PgSelect30[["PgSelect[30∈5]^<br />ᐸrelational_checklistsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgSelectInlineApply111["PgSelectInlineApply[111∈5] ➊<br />ᐳRelationalChecklist"]:::plan
    PgClassExpression17 -->|rejectNull| PgSelect30
    PgSelectInlineApply111 --> PgSelect30
    List113{{"List[113∈5]^<br />ᐸ112,36ᐳ"}}:::plan
    Access112{{"Access[112∈5]^<br />ᐸ30.m.joinDetailsFor54ᐳ"}}:::plan
    PgSelectSingle36{{"PgSelectSingle[36∈5]^<br />ᐸrelational_checklistsᐳ"}}:::plan
    Access112 & PgSelectSingle36 --> List113
    First34{{"First[34∈5]^"}}:::plan
    PgSelectRows35[["PgSelectRows[35∈5]^"]]:::plan
    PgSelectRows35 --> First34
    PgSelect30 --> PgSelectRows35
    First34 --> PgSelectSingle36
    First58{{"First[58∈5]^"}}:::plan
    PgSelectRows59[["PgSelectRows[59∈5]^"]]:::plan
    PgSelectRows59 --> First58
    Lambda114{{"Lambda[114∈5]^<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda114 --> PgSelectRows59
    PgSelectSingle60{{"PgSelectSingle[60∈5]^<br />ᐸrelational_itemsᐳ"}}:::plan
    First58 --> PgSelectSingle60
    PgClassExpression61{{"PgClassExpression[61∈5]^<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle60 --> PgClassExpression61
    PgClassExpression82{{"PgClassExpression[82∈5]^<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgClassExpression61 o--o PgClassExpression82
    PgClassExpression100{{"PgClassExpression[100∈5]^<br />ᐸ__relation...”position”ᐳ"}}:::plan
    PgClassExpression82 o--o PgClassExpression100
    PgSelect30 --> Access112
    List113 --> Lambda114
    PgSelect37[["PgSelect[37∈6]^<br />ᐸrelational_checklist_itemsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgSelectInlineApply115["PgSelectInlineApply[115∈6] ➊<br />ᐳRelationalChecklistItem"]:::plan
    PgClassExpression17 -->|rejectNull| PgSelect37
    PgSelectInlineApply115 --> PgSelect37
    List117{{"List[117∈6]^<br />ᐸ116,43ᐳ"}}:::plan
    Access116{{"Access[116∈6]^<br />ᐸ37.m.joinDetailsFor63ᐳ"}}:::plan
    PgSelectSingle43{{"PgSelectSingle[43∈6]^<br />ᐸrelational_checklist_itemsᐳ"}}:::plan
    Access116 & PgSelectSingle43 --> List117
    First41{{"First[41∈6]^"}}:::plan
    PgSelectRows42[["PgSelectRows[42∈6]^"]]:::plan
    PgSelectRows42 --> First41
    PgSelect37 --> PgSelectRows42
    First41 --> PgSelectSingle43
    First67{{"First[67∈6]^"}}:::plan
    PgSelectRows68[["PgSelectRows[68∈6]^"]]:::plan
    PgSelectRows68 --> First67
    Lambda118{{"Lambda[118∈6]^<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda118 --> PgSelectRows68
    PgSelectSingle69{{"PgSelectSingle[69∈6]^<br />ᐸrelational_itemsᐳ"}}:::plan
    First67 --> PgSelectSingle69
    PgClassExpression70{{"PgClassExpression[70∈6]^<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle69 --> PgClassExpression70
    PgClassExpression88{{"PgClassExpression[88∈6]^<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgClassExpression70 o--o PgClassExpression88
    PgClassExpression106{{"PgClassExpression[106∈6]^<br />ᐸ__relation...”position”ᐳ"}}:::plan
    PgClassExpression88 o--o PgClassExpression106
    PgSelect37 --> Access116
    List117 --> Lambda118

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,__ListTransform11,PgSelectRows12 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item13,PgSelectSingle14 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,__Item15,PgSelectSingle16,PgClassExpression17,PgClassExpression19,Lambda21 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelect23,First27,PgSelectRows28,PgSelectSingle29,First49,PgSelectRows50,PgSelectSingle51,PgClassExpression52,PgClassExpression76,PgClassExpression94,PgSelectInlineApply107,Access108,List109,Lambda110 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgSelect30,First34,PgSelectRows35,PgSelectSingle36,First58,PgSelectRows59,PgSelectSingle60,PgClassExpression61,PgClassExpression82,PgClassExpression100,PgSelectInlineApply111,Access112,List113,Lambda114 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgSelect37,First41,PgSelectRows42,PgSelectSingle43,First67,PgSelectRows68,PgSelectSingle69,PgClassExpression70,PgClassExpression88,PgClassExpression106,PgSelectInlineApply115,Access116,List117,Lambda118 bucket6

